import {
    DeleteDto,
    DeleteStrPrimaryDto,
    SqlQueryDto,
} from '@/common/type/app.dto';
import { omit } from 'lodash';
import { AuthGuard } from '@/common/guard/auth.guard';
import { Body, Controller, ParseIntPipe, Post, Session, UploadedFile, UseGuards, UseInterceptors, UsePipes, ValidationPipe } from '@nestjs/common';
import { ContractCntrCreateDto, ContractCntrSumCreateDto, ContractCntrSumUpdateDto, ContractCreateDto, ContractFeedetCreateDto, ContractFeedetsUpdateDto, ContractTransCreateDto, ContractTransUpdateDto, ContractUpdateDto } from './transport.dto';
import { TransportService } from './transport.service';
import { dot } from 'node:test/reporters';
import { FeedetDto } from '@/business/dto/create-business.dto';


@Controller('transport')
@UseGuards(AuthGuard)
@UsePipes(new ValidationPipe({ whitelist: true }))
export class TransportController {

    constructor(private readonly transService: TransportService) { }

    @Post('contractheadercreate')
    async contractheadercreate(@Body() dto: ContractCreateDto) {
        return await this.transService.createContractHeader(dto);
    }
    @Post('contractheaderupdate')
    async contractheaderupdate(@Body() dto: ContractUpdateDto) {
        return await this.transService.updateContractHeader(dto);
    }
    @Post('contractheaderquery')
    async contractheaderquery(@Body() dto: SqlQueryDto) {
        return await this.transService.queryContractHeader(dto);
    }
    
    @Post('contractquery')
    async contractquery(@Body('contract_id', ParseIntPipe) dto: number) {
        return await this.transService.queryContract(dto);
    }
    @Post('contractdelete')
    async contractdelete(@Body() dto: DeleteDto)  {
        return await this.transService.deleteContract(dto);
    }
    @Post('contractcntrsumquery')
    async contractcntrsumquery(@Body() dto: SqlQueryDto) {
        return await this.transService.queryContractCntrSum(dto);
    }
    @Post('contractcntrsumcreate')
    async contractcntrsumcreate(@Body() dto: ContractCntrSumCreateDto) {
        return await this.transService.createContractCntrSum(dto);
    }
    @Post('contractcntrsumupdate')
    async contractcntrsumupdate(@Body() dto: ContractCntrSumUpdateDto) {
        return await this.transService.updateContractCntrSum(dto);
    }
    @Post('contractcntrsumdelete')
    async contractcntrsumdelete(@Body() dto: DeleteDto) {
        return await this.transService.deleteContractSum(dto);
    }
    @Post('contractcntrcreate')
    async contractcntrcreate(@Body() dto: ContractCntrCreateDto) {
        return await this.transService.createContractCntrs(dto);
    }
    @Post('contractcntrdelete')
    async contractcntrdelete(@Body() dto: DeleteDto) {
        return await this.transService.deleteContractCntrs(dto);
    }
    @Post('contractcntrquery')
    async contractcntrquery(@Body() dto: SqlQueryDto) {
        return await this.transService.queryContractCntrs(dto);
    }
    @Post('contracttranscreate')
    async contracttranscreate(@Body() dto: ContractTransCreateDto) {
        return await this.transService.createContractTrans(dto);
    }
    @Post('contracttransupdate')
    async contracttransupdate(@Body() dto: ContractTransUpdateDto) {
        return await this.transService.updateContractTrans(dto);
    }
    @Post('contracttransdelete')
    async contracttransdelete(@Body() dto: DeleteDto) {
        return await this.transService.deleteContractTrans(dto);
    }
    @Post('contractfeedetscreate')
    async createfeedet(@Body() data: ContractFeedetCreateDto, @Session() session: Record<string, any>) {
        data.fee_nam = session['user']['name'];
        return await this.transService.createContractFeedet(data);
    }
    @Post('contractfeedetsupdate')
    async updatefeedet(@Body() data: ContractFeedetsUpdateDto) {
        return await this.transService.updateContractFeedet(data);
    }
    @Post('contractfeedetsdelete')
    async deletecontractfeedets(@Body() data: DeleteDto) {
        return await this.transService.deleteContractFeedets(data);
    }    
}
